import sys
ADDRESS_COLOR = '\x1b[37;1m'  # Синий
HEX_COLOR = '\x1b[34;1m'  # Зеленый
DATA_COLOR = '\x1b[37;1m'  # Желтый
RESET_COLOR = '\033[0m'  # Сброс цвета

def hexdump(file_path, start_offset=None, end_offset=None):
    with open(file_path, 'rb') as file:
        offset = 0
        while True:
            chunk = file.read(16)
            if not chunk:
                break

            if (start_offset is None or offset >= start_offset) and (end_offset is None or offset < end_offset):
                address = f'{offset:08X}'
                hex_data = ' '.join(f'{byte:02X}' for byte in chunk)
                printable_data = ''.join(chr(byte) if 32 <= byte < 127 else '.' for byte in chunk)

                line = f'{ADDRESS_COLOR}{address}{RESET_COLOR}  {HEX_COLOR}{hex_data}{RESET_COLOR}  {DATA_COLOR}{printable_data}{RESET_COLOR}'
                print(line)
            offset += 16

#hexdump("/home/student/Документы/base.sqlite", 100, 200)
            
file = cmd.split(' ')
if len(file) == 2:
    hexdump(file[1])
elif len(file) == 4:
    hexdump(file[1], int(file[2]), int(file[3]))
else:
    print("Usage: hexdump <file_path> [<start_offset> <end_offset>]")
